package com.xuanyuan.material

import android.os.Bundle
import android.widget.CompoundButton
import com.xuanyuan.baselibaray.BaseActivity
import com.xuanyuan.material.databinding.ActivitySwitchMaterialBinding


class SwitchMaterialActivity : BaseActivity<ActivitySwitchMaterialBinding>() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)

        //SwitchCompat被竖线隔开
        mBinding.switchCompat.splitTrack = true;

        //SwitchCompat右边会出现错误提示
        mBinding.switchCompat.error = "error";

        //是否显示文字[默认为 开启/关闭](当然也可以自定义文字)
        mBinding.switchCompat.showText = true;

        //自定义文字
        mBinding.switchCompat.textOff = "Off";
        mBinding.switchCompat.textOn = "On";

        //设置左边文字和右边按钮的距离
        mBinding.switchCompat.switchPadding = 20;

        //设置关闭和开启
        mBinding.switchCompat.isChecked = true;
        
        //监听switchCompat开启和关闭变化
        mBinding.switchCompat.setOnCheckedChangeListener(CompoundButton.OnCheckedChangeListener { buttonView, isChecked ->  });

        //设置Track图标
        mBinding.switchCompat.setTrackResource(R.drawable.ic_icon_outline_eye);

        //switchCompat设置指示图标[但是开启和关闭都是一个图标,可以在setOnCheckedChangeListener里动态设置]
        mBinding.switchCompat.setThumbResource(R.drawable.ic_icon_outline_eye_close);

    }

    override fun initLayout(): Int {
        return R.layout.activity_switch_material
    }


}